#pragma once
#include "../external/external.h"
#include <vector>

namespace Nitro::Renderer {

enum BindFlags
{
    VertexBuffer = 0x8892,
    IndexBuffer = 0x8893,
    UniformBuffer = 0x88A1,
};

enum Format
{
    R32Float = 0,
    RG32Float = 1,
    RGB32Float = 2,
    RGBA32Float = 3,
    R64Double = 4,
    RG64Double = 5,
    RGB64Double = 6,
    RGBA64Double = 7,
    R8UInt = 8,
    RG8UInt = 9,
    RGB8UInt = 10,
    RGBA8UInt = 11,
};

struct VertexAttribute
{
    uint32_t location;
    uint32_t offset;
    uint32_t stride;
    Format format;
};

struct BufferDescriptor
{
    uint32_t size;
    uint32_t stride;
    BindFlags bindFlags;
    std::vector<VertexAttribute> vertexAttribs;
    void appendAttribute(uint32_t offset, uint32_t stride, Format format);
    void appendAttribute(uint32_t location, uint32_t offset, uint32_t stride,
                         Format format);
};

struct Buffer
{
    union
    {
        struct
        {
            uint32_t vao, vbo;
        };
        uint64_t id;
    };
};

Buffer CreateBuffer(const BufferDescriptor& desc, const void* data);

} // namespace Nitro::Renderer